# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

from jiage315.model import MedicineModel, init_db, engine
from jiage315.items import MedicineItem


class HospNewsPipeline(object):
    def __init__(self):
        init_db(engine)

    def process_item(self, item, spider):
        if type(item) == MedicineItem:
            MedicineModel.save_model(MedicineModel(), item)
        return item
